package com.dm.hdfxxt.common;

import net.sf.json.JSONObject;

import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.Map;

public class SessionAndGetRemote {

    public static Integer SessionQuery(HttpSession session){
        //查看session是否存在，不存在返回登陆页面
        String username = session.getAttribute("username")!=null?session.getAttribute("username").toString():null;
        String Store = session.getAttribute("store")!=null?session.getAttribute("store").toString():null;
        String userno = session.getAttribute("userno")!=null?session.getAttribute("userno").toString():null;
        JSONObject js = new JSONObject();
        if(username==null||Store==null||userno==null){
            return -1;
        }
        return 1;

    }

    public static Map<String,Object> getRemoteResult(Map<String,Object> param, String url, OkHttpUtils okHttpUtils){
        JSONObject jsonObject = JSONObject.fromObject(param);
        Map<String,String> headersParams = new HashMap<String,String>();
        headersParams.put("Content-Type","application/json;UTF-8");
        Map<String,Object> statusMap = okHttpUtils.sendPostJson(url,headersParams,jsonObject.toString(),new Object());
        return  statusMap;
    }

}
